//
//  SXHBaseScriptMessage.h
//  ZLZKBaseUtils
//
//  Created by sxh on 2020/12/14.
//

#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>
@class SXHBaseWebView;

typedef void(^CallBack)(NSString * _Nullable result);

NS_ASSUME_NONNULL_BEGIN

@interface SXHBaseScriptMessage : NSObject

- (instancetype)initWithWebview:(WKWebView*)webview dict:(NSDictionary *)dict completionHandler:(CallBack)completionHandler;

/*! 消息名称，对应调用accessNative时的name参数 */
@property (nonatomic, copy, readonly) NSString *name;

/*! 消息的附加信息，对应调用accessNative时的params参数 */
@property (nonatomic, copy, readonly) id userInfo;

//回调函数
- (void)callbackWithRet:(id)ret;

@end


@protocol SXHBaseScriptMessageDelegate <NSObject>

- (void)webView:(SXHBaseWebView *)webView didReceiveScriptMessage:(SXHBaseScriptMessage *)scriptMessage;

@end

NS_ASSUME_NONNULL_END
